package cn.hema.controller;

import cn.hema.Client.RelationshipServiceClient;

import cn.hema.model.BorrowRecord;
import cn.hema.model.Message;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.bridge.IMessage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

@AllArgsConstructor
@RestController
@Slf4j
public class RelationshipServiceClientController {
    @Qualifier("cn.hema.Client.RelationshipServiceClient")
    @Autowired
    private final RelationshipServiceClient relationshipServiceClient;


    @PostMapping("/add")
    public ResponseEntity<Message> addRE(@RequestBody BorrowRecord borrowRecord) {
        Message message = relationshipServiceClient.addRE(borrowRecord);
        return ResponseEntity.ok(message);
    }

    @PostMapping("/back")
    public ResponseEntity<Message> back(@RequestBody BorrowRecord borrowRecord) {
        Message message = relationshipServiceClient.back(borrowRecord);
        return ResponseEntity.ok(message);
    }

}